#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
typedef struct Node
{
	int val;
	struct Node* l;
	struct Node* r;
	Node(int x) :val(x), l(NULL), r(NULL) {};
}Tnode, * Tree;

Tree build(Tree T)
{
	int x;
	scanf("%d", &x);
	if (x == 0)
	{
		return NULL;
	}
	else
	{
		T = new Node(x);
		T->l = build(T->l);
		T->r = build(T->r);
	}
	return T;
}

vector<int> v;
vector<vector<int> > ans;
void Find(Tree T, int sum)
{
	if (!T) return;
	sum = sum - T->val;
	v.push_back(T->val);

	if (!T->l && !T->r && !sum)
	{
		ans.push_back(v);
	}

	else
	{
		Find(T->l, sum);
		Find(T->r, sum);
	}

	v.pop_back();
}
int main()
{
	int sum;
	Tree T;
	T = build(T);
	cin >> sum;
	Find(T, sum);
	cout << ans.size() << endl;
	for (auto p : ans)
	{
		for (auto j : p)
		{
			printf("%d ", j);
		}
		printf("\n");
	}
}